package com.ehotting.edsta.diagnosisPredict.controller;

import com.ehotting.eaf.core.domain.R;
import com.ehotting.eaf.core.web.controller.BaseController;
import com.ehotting.eaf.core.web.domain.diagnosisPredict.PageDto;
import com.ehotting.edsta.diagnosisPredict.domain.dto.*;
import com.ehotting.edsta.diagnosisPredict.feign.DiagnosisPredictFeignService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "DiagnosisPredictController", description = "零散的算法模块接口")
@RestController
@RequestMapping
public class DiagnosisPredictController extends BaseController {

    @Autowired
    private DiagnosisPredictFeignService diagnosisPredictFeignService;

    /**
     * 获取模型详情
     *
     * @param predictListDto
     * @return
     */
    @ApiOperation(value = "搜索预测任务",notes = "返回的数据类型：PageDto\\<PublishPredictTaskDto\\>")
    @ApiResponses(value = {
            @ApiResponse(code = 1,message = "分页实体PageDto",response = PageDto.class),
            @ApiResponse(code = 2,message = "预测任务实体PublishPredictTaskDto",response = PublishPredictTaskDto.class)
    })
    @PostMapping(value = "/predicttask/predict-task/search")
    public R<PageDto<PublishPredictTaskDto>> searchPredictTask(@RequestBody PredictListDto predictListDto) {
        return R.convert(diagnosisPredictFeignService.searchPredictTask(predictListDto));
    }


    /**
     * 获取算法接口（进入加载）
     *
     * @param projectType
     * @return
     */
    @ApiOperation(value = "获取算法接口（进入加载）",notes = "返回的数据类型：List\\<AlgorithmInfoDto\\>")
    @ApiResponses(value = {
            @ApiResponse(code = 1,message = "集合",response = List.class),
            @ApiResponse(code = 2,message = "算法详情",response = AlgorithmInfoDto.class)
    })
    @GetMapping(value = "/classify/get-algorithm-by-type")
    public R<List<AlgorithmInfoDto>> getAlgorithmByType(@RequestParam("projectType") String projectType) {
        return R.convert(diagnosisPredictFeignService.getAlgorithmByType(projectType));
    }


    /**
     * 发布模型
     *
     * @param req
     * @return
     */
    @ApiOperation("发布模型")
    @PostMapping(value = "/publishtask/publish-task-data/publish")
    public R<Boolean> publish(@RequestBody PublishTaskDataReqDto req) {
        return R.convert(diagnosisPredictFeignService.publish(req));
    }

    /**
     * 原始数据文件属性字段列表列表
     *
     * @return
     */
    @ApiOperation(value = "原始数据文件属性字段列表",notes = "返回的数据类型：List\\<FeDatafield\\>")
    @ApiResponses(value = {
            @ApiResponse(code = 1,message = "集合",response = List.class),
            @ApiResponse(code = 2,message = "原始数据文件属性字段",response = FeDatafield.class)
    })
    @GetMapping(value = "/feDatafield/list")
    public R<List<FeDatafield>> list(String createTime, Long datafileId, Long id, String name, String name2, String type) {
        return R.convert(diagnosisPredictFeignService.list(createTime, datafileId, id, name, name2, type));
    }

    /**
     * 条件过滤字段列表
     *
     * @return
     */
    @ApiOperation("条件过滤字段列表")
    @PostMapping(value = "/feFilterRule/saveOrUpdateBatch")
    public R<String> saveOrUpdateBatchFilterRule(@RequestBody FeFilterRule[] t) {
        return R.convert(diagnosisPredictFeignService.saveOrUpdateBatchFilterRule(t));
    }

    /**
     * 缺失值处理字段列表
     *
     * @return
     */
    @ApiOperation("缺失值处理字段列表")
    @PostMapping(value = "/feMissingRule/saveOrUpdateBatch")
    public R<String> saveOrUpdateBatchMissingRule(@RequestBody FeMissingRule[] t) {
        return R.convert(diagnosisPredictFeignService.saveOrUpdateBatchMissingRule(t));
    }

    /**
     * 重复值处理字段列表
     *
     * @return
     */
    @ApiOperation("重复值处理字段列表")
    @PostMapping(value = "/feDuplicateRule/saveOrUpdateBatch")
    public R<String> saveOrUpdateBatchDuplicateRule(@RequestBody FeDatafield[] t) {
        return R.convert(diagnosisPredictFeignService.saveOrUpdateBatchDuplicateRule(t));
    }

    /**
     * 属性生成字段列表
     *
     * @return
     */
    @ApiOperation("属性生成字段列表")
    @PostMapping(value = "/feAttributecreateRule/saveOrUpdateBatch")
    public R<String> saveOrUpdateBatchAttrCreateRule(@RequestBody FeAttributecreateRule[] t) {
        return R.convert(diagnosisPredictFeignService.saveOrUpdateBatchAttrCreateRule(t));
    }

    /**
     * 数据标准化字段列表
     *
     * @return
     */
    @ApiOperation("数据标准化字段列表")
    @PostMapping(value = "/feStandardRule/saveOrUpdateBatch")
    public R<String> saveOrUpdateBatchStandardRule(@RequestBody FeStandardRule[] t) {
        return R.convert(diagnosisPredictFeignService.saveOrUpdateBatchStandardRule(t));
    }
}
